import request from '@/plugin/axios'

export function fetchList (data) {
  return request({
    url: '/mdse/querySpuList',
    method: 'get',
    params: data
  })
}

export function getCategoryList (data) {
  return request({
    url: '/category/list',
    method: 'get',
    params: data
  })
}

export function getAftersaleConfList (data) {
  return request({
    url: '/aftersaleConf/list',
    method: 'get',
    params: data
  })
}

export function createOrEdit (data) {
  return request({
    url: '/mdse/save',
    method: 'post',
    data
  })
}

export function deleteById (data) {
  return request({
    url: '/mdse/del?spuIds=' + data,
    method: 'post',
  })
}

export function upOrDownSpu (upOrDown, data) {
  return request({
    url: '/mdse/status/' + upOrDown,
    method: 'post',
    data
  })
}

export function upOrDownSku (upOrDown, data) {
  return request({
    url: '/mdse/upOrDownSku',
    method: 'get',
    params: {
      skuId: data,
      upOrDown: upOrDown
    }
  })
}

export function spuDetailById (data) {
  return request({
    url: '/mdse/spuDetailById/' + data,
    method: 'get'
  })
}

export function querySkuList (data) {
  return request({
    url: '/mdse/querySkuList/' + data,
    method: 'get'
  })
}

export function createOrEditSku (data) {
  // 元转分
  data.listPrice = data.listPrice * 100;
  data.unitPrice = data.unitPrice * 100;

  return request({
    url: '/mdse/insertOrUpdateSku',
    method: 'post',
    data
  })
}

export function deleteSkuById (data) {
  return request({
    url: '/mdse/delSku?skuId=' + data,
    method: 'get',
  })
}

export function updateSpu (data) {
  return request({
    url: '/mdse/updateSpu',
    method: 'post',
    data
  })
}

export function setIntegral (data) {
  return request({
    url: '/integralMdse/savebatch',
    method: 'post',
    data
  })
}

export function queryIntegralBySkuId (data) {
  return request({
    url: '/integralMdse/' + data,
    method: 'get',
  })
}

export function querySpuTuihhgz (data) {
  return request({
    url: '/aftersaleConf/bySpuId/' + data,
    method: 'post'
  })
}

export function setSpuTuihhgz (tuihhgzId, data) {
  return request({
    url: '/aftersaleConf/setSpuRela/' + tuihhgzId,
    method: 'post',
    data
  })
}

export function clearCache () {
  return request({
    url: '/mdse/clearCache',
    method: 'get',
  })
}